#
# Makefile for the FREAX-kernel.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#

AR	=gar
AS	=as --32
LD	=ld -melf_i386
LDFLAGS	=-s -x
CC	=gcc -m32
CFLAGS	=-w -O -fstrength-reduce -fomit-frame-pointer \
	-finline-functions -nostdinc -I../include -fno-stack-protector
CPP	=gcc -E -nostdinc -I../include

.c.s:
	$(CC) $(CFLAGS) \
	-S -o $*.s $<
.s.o:
	$(AS) -c -o $*.o $<
.c.o:
	$(CC) $(CFLAGS) \
	-c -o $*.o $<

OBJS  = sched.o console.o tty_io.o printk.o vsprintf.o
#	system_call.o traps.o asm.o fork.o \
	panic.o mktime.o vsprintf.o \
	keyboard.o rs_io.o hd.o sys.o exit.o serial.o

kernel.o: $(OBJS)
	$(LD) -r -o kernel.o $(OBJS)
	sync

clean:
	rm -f core *.o *.a tmp_make
	for i in *.c;do rm -f `basename $$i .c`.s;done

dep:
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \
		$(CPP) -M $$i;done) >> tmp_make
	cp tmp_make Makefile

### Dependencies:
console.s console.o: console.c ../include/asm/io.h ../include/asm/system.h \
 ../include/linux/tty.h ../include/termios.h
printk.s printk.o: printk.c ../include/stdarg.h ../include/stddef.h
sched.s sched.o: sched.c
tty_io.s tty_io.o: tty_io.c ../include/linux/tty.h ../include/termios.h
